package com.funny.rabbitmq.workqueues;

import com.funny.rabbitmq.utils.RabbitMQUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

public class Producer {

    private final static String QUEUE_NAME = "workqueues";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();

        channel.queueDeclare(QUEUE_NAME, false, false, false, null);
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int i = scanner.nextInt();
            String msg = "hello world_" + i;
            channel.basicPublish("", QUEUE_NAME, null, msg.getBytes());
            System.out.println("消息发送成功");
        }
    }
}
